package com.aivin.popuwindowdemo.bean;

import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import com.aivin.popuwindowdemo.tool.BgRoundRectShapeTool;


/**
 * 带圆角按钮背景 StateListDrawable
 */
public class BgDrawable extends StateListDrawable {
    public BgDrawable(int mRadius ,int colorNomal , int   colorPress) {
        ShapeDrawable drawablePress = new ShapeDrawable( BgRoundRectShapeTool.getRoundRectShap(mRadius, mRadius, mRadius, mRadius) );
        drawablePress.getPaint().setColor( colorPress);
        ShapeDrawable defaultDrawable = new ShapeDrawable( BgRoundRectShapeTool.getRoundRectShap(mRadius, mRadius, mRadius, mRadius) );
        defaultDrawable.getPaint().setColor(colorNomal);
        addState(new int[]{android.R.attr.state_pressed}, drawablePress);
        addState(new int[]{-android.R.attr.state_pressed}, defaultDrawable);
    }
}
